// Copyright (c) 2009 Hypirinha contributers
// This program is made available under the terms of the MIT License.
package org.hypirinha.html;

import java.io.File;
import java.io.FilenameFilter;
import java.util.List;
import java.util.ArrayList;

public class DirectoryUtils {
    static List<File> recursiveList(File directory, FilenameFilter filter) {
        List<File> output = new ArrayList<File>();
        File[] files = directory.listFiles();
        for (File file : files) {
            if (file.isDirectory()) {
                output.addAll(recursiveList(file, filter));
            } else {
                if (filter.accept(directory, file.toString())) {
                    output.add(file);
                }
            }
        }
        return output;
    }
}
